package com.ordertracker.entity;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Description of class.
 * Created 1/18/13 2:34 PM
 *
 * @author andrey.rodin@playtech.com
 */

@XmlRootElement
public class Organization extends VersionedEntity {

    private static final long serialVersionUID = -800077276418655657L;
    private String shortName;
    private String fullName;
    private int code;
    private String prefix;
    private String description;

    public Organization() {
    }

    public Organization(String shortName, String fullName, int code, String prefix, String description) {
        this.shortName = shortName;
        this.fullName = fullName;
        this.code = code;
        this.prefix = prefix;
        this.description = description;
    }

    @XmlElement(nillable = false)
    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    @XmlElement
    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    @XmlElement
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @XmlElement(nillable = false)
    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    @XmlElement
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Organization)) return false;
        if (!super.equals(o)) return false;

        Organization that = (Organization) o;

        if (code != that.code) return false;
        if (description != null ? !description.equals(that.description) : that.description != null) return false;
        if (fullName != null ? !fullName.equals(that.fullName) : that.fullName != null) return false;
        if (!prefix.equals(that.prefix)) return false;
        if (!shortName.equals(that.shortName)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + shortName.hashCode();
        result = 31 * result + (fullName != null ? fullName.hashCode() : 0);
        result = 31 * result + code;
        result = 31 * result + prefix.hashCode();
        result = 31 * result + (description != null ? description.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Organization{" +
                "shortName='" + shortName + '\'' +
                ", fullName='" + fullName + '\'' +
                ", code=" + code +
                ", prefix='" + prefix + '\'' +
                ", description='" + description + '\'' +
                ", " + super.toString();
    }
}
